package com.chenchao.reflection;

import java.beans.BeanInfo;
import java.beans.IntrospectionException;
import java.beans.Introspector;
import java.beans.PropertyDescriptor;

/**
 * @encoding : UTF-8
 * @Time : 2020/12/8 19:45
 * @Author : Chen Chao
 * @File : javaSE.com.chenchao.reflection.Test14.java
 * @Software : IntelliJ IDEA
 * @since : 1.8
 * 内省
 */
public class Test14 {
    public static void main(String[] args) throws IntrospectionException {
        /*获取字节码属性信息,排除指定父类继承内容*/
        BeanInfo beanInfo = Introspector.getBeanInfo(Fish.class,Object.class);
        /*获取所有属性*/
        PropertyDescriptor[] pds = beanInfo.getPropertyDescriptors();
        for (PropertyDescriptor pd : pds) {
            /*获取get/set方法*/
            pd.getReadMethod();
            pd.getWriteMethod();
        }
    }
}
